<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>显示所有员工</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
</head>
<body>
<h1>欢迎您,${sessionScope.loginUser.name}</h1>
<h2>展示员工列表</h2>
<a href="${pageContext.request.contextPath}/manager/addEmp.jsp" class="btn btn-success">新增员工</a>
<table class="table table-responsive table-striped">
    <tr>
        <td>ID</td>
        <td>名字</td>
        <td>工资</td>
        <td>年龄</td>
        <td>操作</td>
    </tr>
    <c:forEach var="e" items="${requestScope.empList}">
        <tr>
            <td>${e.id}</td>
            <td>${e.name}</td>
            <td>${e.salary}</td>
            <td>${e.age}</td>
            <td>
                <a href="${pageContext.request.contextPath}/ToEditEmp?id=${e.id}" class="btn btn-info">编辑</a>
                <a href="${pageContext.request.contextPath}/DeleteEmp?id=${e.id}" class="btn btn-info">删除</a>
            </td>
        </tr>
    </c:forEach>

</table>
<div class="container">
    <div class="row">
        <div class="text-center">
            <ul class="pagination">
                <%-- 上一页 --%>

                <c:if test="${requestScope.page.pageIndex>1}">
                    <li><a href="${pageContext.request.contextPath}/showAll?pageIndex=${requestScope.page.pageIndex-1}">&lt;&lt;</a>
                    </li>
                </c:if>

                <c:forEach var="p" begin="1" end="${requestScope.page.totalPage}" varStatus="status">
                    <li class="<c:if test='${status.count == requestScope.page.pageIndex }'>active</c:if>"><a
                            href="${pageContext.request.contextPath}/showAll?pageIndex=${p}">${p}</a></li>
                </c:forEach>

                <%-- 下一页 --%>
                <c:if test="${requestScope.page.pageIndex < requestScope.page.totalPage}">
                    <li><a href="${pageContext.request.contextPath}/showAll?pageIndex=${requestScope.page.pageIndex+1}">&gt;&gt;</a>
                    </li>
                </c:if>
            </ul>
        </div>
    </div>
</div>
</body>
</html>
